Test test

Gabin, essaye de rajouter du texte en dessous de cette phrase et de supprimer “Test test” au dessus pour voir comment ça marche pour les Pull request !

<<<<<<< HEAD

ca dit quoi la

Cette ligne est une ligne ajoutée le 07/04 à 11h pour test pull. >>>>>>> ba02fe12b344d1e11cf446dc9c3c24d5e9df7e0e

je rajoute quelque chose pour voir si ca marche

Le document commence ici

Etude sur les cas de Covid-19 recensés

library(dplyr) ## pensez à mettre les libraries ici, on s'y retrouvera plus facilement
library(ggplot2)
library(tidyr)
library(plotly)
library(kableExtra)
library(readr)
library(readxl)
library(dplyr)
library(rAmCharts)
coronavirus <- utils::read.csv("https://raw.githubusercontent.com/RamiKrispin/coronavirus-csv/master/coronavirus_dataset.csv")## URL permettant de générer la data
summary_df <- coronavirus %>% group_by(Country.Region, type) %>%
  summarise(total_cases = sum(cases)) %>%
  arrange(-total_cases)

summary_df %>% head(20)
## # A tibble: 20 x 3
## # Groups:   Country.Region [13]
##    Country.Region type      total_cases
##    <fct>          <fct>           <int>
##  1 US             confirmed      461437
##  2 Spain          confirmed      153222
##  3 Italy          confirmed      143626
##  4 France         confirmed      118781
##  5 Germany        confirmed      118181
##  6 China          confirmed       82883
##  7 China          recovered       77679
##  8 Iran           confirmed       66220
##  9 United Kingdom confirmed       65872
## 10 Germany        recovered       52407
## 11 Spain          recovered       52165
## 12 Turkey         confirmed       42282
## 13 Iran           recovered       32309
## 14 Italy          recovered       28470
## 15 US             recovered       25410
## 16 Belgium        confirmed       24983
## 17 Switzerland    confirmed       24051
## 18 France         recovered       23413
## 19 Netherlands    confirmed       21903
## 20 Canada         confirmed       20654
coronavirus %>% 
  filter(date == max(date)) %>%
  select(country = Country.Region, type, cases) %>%
  group_by(country, type) %>%
  summarise(total_cases = sum(cases)) %>%
  pivot_wider(names_from = type,
              values_from = total_cases) %>%
  arrange(-confirmed)
## # A tibble: 184 x 4
## # Groups:   country [184]
##    country        confirmed death recovered
##    <fct>              <int> <int>     <int>
##  1 US                 32385  1783      1851
##  2 Spain               5002   655      4144
##  3 Germany             4885   258      6107
##  4 France              4822  1341      1961
##  5 United Kingdom      4398   882        14
##  6 Italy               4204   610      1979
##  7 Turkey              4056    96       296
##  8 Brazil              1922   131        46
##  9 Iran                1634   117      2497
## 10 Belgium             1580   283       483
## # … with 174 more rows
CoronavirusFR <- filter(coronavirus, Country.Region == "France" & Province.State == "") ## j'ai mis Province.State "", comme ça on a pas l'OutreMer
ggplot(CoronavirusFR) +
 aes(x = date, fill = type, colour = type, weight = cases) +
 geom_bar() +
 scale_fill_hue() +
 scale_color_hue() +
 labs(y = "Nombre de cas", title = "Coronavirus en France", caption = "Source : Rami Krispin dataset coronavirus") +
 ggthemes::theme_stata() ## graphique des nouveaux cas chaque jour (non-cumulé)

CoronavirusIT <- filter(coronavirus, Country.Region == "Italy")
ggplot(CoronavirusIT) +
 aes(x = date, fill = type, colour = type, weight = cases) +
 geom_bar() +
 scale_fill_hue() +
 scale_color_hue() +
 labs(y = "Nombre de cas", title = "Coronavirus en Italie", caption = "Source : Rami Krispin dataset coronavirus") +
 ggthemes::theme_stata() ## graphique des nouveaux cas chaque jour (non-cumulé)

CoronavirusDE <- filter(coronavirus, Country.Region == "Germany")
ggplot(CoronavirusDE) +
 aes(x = date, fill = type, colour = type, weight = cases) +
 geom_bar() +
 scale_fill_hue() +
 scale_color_hue() +
 labs(y = "Nombre de cas", title = "Coronavirus en Allemagne", caption = "Source : Rami Krispin dataset coronavirus") +
 ggthemes::theme_stata() ## graphique des nouveaux cas chaque jour (non-cumulé)

CoronavirusSPA <- filter(coronavirus, Country.Region == "Spain")
ggplot(CoronavirusSPA) +
 aes(x = date, fill = type, colour = type, weight = cases) +
 geom_bar() +
 scale_fill_hue() +
 scale_color_hue() +
 labs(y = "Nombre de cas", title = "Coronavirus en Espagne", caption = "Source : Rami Krispin dataset coronavirus") +
 ggthemes::theme_stata() ## graphique des nouveaux cas chaque jour (non-cumulé)

CoronavirusUK <- filter(coronavirus, Country.Region == "United Kingdom")
ggplot(CoronavirusUK) +
  aes(x= date, fill = type, colour = type, weight = cases) + 
  geom_bar() +
  scale_fill_hue() + 
  scale_color_hue() + 
  labs(y = "Nombre de cas", title = "Coronavirus au Royaume-Uni", caption = "Source : Rami Krispin dataset coronavirus") + 
  ggthemes::theme_stata()

CombineCountries <- filter(coronavirus, Country.Region == "France" | Country.Region == "Spain" | Country.Region == "Germany" | Country.Region == "Italy")
CombineGraph <-ggplot(CombineCountries, aes(date, cases))

CombineGraph2 <- CombineGraph + geom_bar(stat = "identity", aes(fill = type)) +
  facet_wrap(~ Country.Region) +
  xlab("Date") + 
  ggtitle("Cas de coronavirus") +
  theme_linedraw()

CombineGraph3 <- CombineGraph2 + theme(axis.title.y = element_blank()) 

CombineGraph3 <- ggplotly(CombineGraph3)
CombineGraph3 ## graphique de comparaison interactif des nouveaux cas chaque jour (non-cumulé)
DataCountries <- CombineCountries %>% group_by(Country.Region, type) %>%
  summarise(total_cases = sum(cases)) %>%
  arrange(Country.Region)
DataCountries2 <- spread(DataCountries, "type", "total_cases")
DataCountries2$confirmed <- as.numeric(DataCountries2$confirmed)
DataCountries2$death <- as.numeric(DataCountries2$death)
DataCountries2$recovered <- as.numeric(DataCountries2$recovered) 
DataCountries2$"Ratio death/confirmed" <- DataCountries2$death/DataCountries2$confirmed*100
#DataCountries2$"Ratio recovered/confirmed" <- DataCountries2$recovered/DataCountries2$confirmed*100
library(kableExtra)
kable(DataCountries2) %>%
  kable_styling("striped", full_width = F) %>%
  column_spec(3, bold = T) %>%
  row_spec(1, bold = T, color = "white", background = "blue") %>%
  row_spec(2, bold = T, color = "white", background = "red") %>%
  row_spec(3, bold = T, color = "white", background = "green") %>%
  row_spec(4, bold = T, color = "white", background = "orange") ## à voir si on rajoute le ratio recovered/confirmed (pas sûr que ce soit pertinent)
Country.Region confirmed death recovered Ratio death/confirmed
France 118781 12228 23413 10.294576
Germany 118181 2607 52407 2.205938
Italy 143626 18279 28470 12.726804
Spain 153222 15447 52165 10.081450

Faire une courbe cumulative des confirmés et des décédés

summary_df2 <- spread(coronavirus, "type", "cases")
SpreadCountries <- filter(summary_df2, Country.Region == "France" & Province.State == "" | Country.Region == "Spain" | Country.Region == "Germany" | Country.Region == "Italy") 
SpreadCountries1 <- SpreadCountries[,-1]
CountriesConfirmed <- SpreadCountries1 %>% group_by(Country.Region) %>% mutate(CumulConfirmes=cumsum(confirmed))
ggplot(CountriesConfirmed) +
 aes(x = date, y = CumulConfirmes, colour = Country.Region) +
 geom_line(size = 1L) +
 scale_color_hue() +
 labs(y = "Nombre de cas confirmés (cumulés)", title = "Nombre de personnes infectées par le Covid-19") +
 ggthemes::theme_stata() ## graphique cumulatif des cas confirmés de Covid-19 

CountriesDeath <- SpreadCountries1 %>% group_by(Country.Region) %>%  mutate(CumulMort=cumsum(death))
ggplot(CountriesDeath) +
 aes(x = date, y = CumulMort, colour = Country.Region) +
 geom_line(size = 1L) +
 scale_color_hue() +
 labs(y = "Nombre de décès (cumulés)", title = "Décès liés au Covid-19") +
 ggthemes::theme_stata() ## graphique cumulatif des cas de décés dû au Covid-19 

LeftJoin1 <- left_join(CountriesConfirmed, CountriesDeath, by = c("Country.Region", "Lat", "Long", "date", "confirmed", "death", "recovered"))

CountriesRecovered <- SpreadCountries1 %>% group_by(Country.Region) %>%  mutate(CumulSoigne=cumsum(recovered))

LeftJoin2 <- left_join(LeftJoin1, CountriesRecovered, by = c("Country.Region", "Lat", "Long", "date", "confirmed", "death", "recovered"))

LeftJoin2$confirmed <- NULL
LeftJoin2$death <- NULL
LeftJoin2$recovered <- NULL
LeftJoin2$Lat <- NULL
LeftJoin2$Long <- NULL

LeftJoin2$CumulConfirmes <- as.numeric(LeftJoin2$CumulConfirmes)
LeftJoin2$CumulMort <- as.numeric(LeftJoin2$CumulMort)
LeftJoin2$CumulSoigne <- as.numeric(LeftJoin2$CumulSoigne)

FinalCumul <- LeftJoin2 %>% gather(Total, Value, -Country.Region, -date)
ggplot(FinalCumul) +
 aes(x = date, y = Value, colour = Country.Region, group = Country.Region) +
 geom_line(size = 1L) +
 scale_color_hue() +
 labs(y = "Effectifs cumulés (par catégorie)", title = "Graphique de l'évolution du Covid-19") +
 ggthemes::theme_stata() +
 facet_wrap(vars(Total), scales = "free") ## à voir si on peut pas faire un graph plus parlant

CombineCumul <-ggplot(FinalCumul, aes(date, Value))

CombineCumul2 <- CombineCumul + geom_bar(stat = "identity", aes(fill = Total)) +
  facet_wrap(~ Country.Region) +
  xlab("Date") + 
  ggtitle("Effectifs cumulés par catégorie de l'évolution du Covid-19") +
  theme_linedraw()

CombineCumul3 <- CombineCumul2 + theme(axis.title.y = element_blank()) 

CombineCumul3 <- ggplotly(CombineCumul3)
CombineCumul3 ## graph interactif sur les effectifs cumulés

Évolution du CAC 40

CAC40 <- read_xlsx("PX1-3.xlsx")

CAC40$date <- as.Date(CAC40$date)

ggplot(CAC40) +
 aes(x = date, y = cloture) +
 geom_line(size = 0.78) +
 scale_color_hue() +
 labs(x = "Date", y = "Cours de cloture", title = "Évolution de l'indice boursier CAC 40", subtitle = "Depuis janvier 2020") +
 hrbrthemes::theme_modern_rc()

Évolution du S&P 500

SP500 <- read_xlsx("SPX.xlsx")

SP500$date <- as.Date(SP500$date) #mettre la colonne date sous le bon format
SP500 <- dplyr::rename(SP500, cloture = fermeture)

ggplot(SP500) +
 aes(x = date, y = cloture) +
 geom_line(size = 0.78, colour = "#0c4c8a") +
 labs(x = "Date", y = "Cours de cloture", title = "Evolution du S&P 500", subtitle = "depuis janvier 2020") +
 hrbrthemes::theme_modern_rc()